package com.xckj.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.xckj.entity.ProjectInfo;
import com.xckj.service.ProjectInfoService;
import com.xckj.utils.ReturnT;

/**
 * @description 数据库配置
 * @author yanchf
 * @date 2023-12-10
 */
@Service
public class ProjectInfoServiceImpl implements ProjectInfoService {
	@Value("${app.project.name}")
	public String appName;


	@Override
	public Object insert(ProjectInfo projectInfo) {

		// valid
		if (projectInfo == null) {
			return ReturnT.error("必要参数缺失");
        }

        return ReturnT.success();
	}


	@Override
	public Object delete(int id) {
		int ret = 0;
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public Object update(ProjectInfo projectInfo) {
		int ret = 0;
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public ProjectInfo load(int id) {
		return null;
	}


	@Override
	public Map<String,Object> pageList(int offset, int pagesize) {
		List<ProjectInfo> pageList = new ArrayList<>();
		int totalCount = 1;
		ProjectInfo project = new ProjectInfo();
		project.setProjectname(appName);
		pageList.add(project);
		
		// result
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("pageList", pageList);
		result.put("totalCount", totalCount);

		return ReturnT.success(result);
	}

}